/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Server;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.SSLServerSocket;

/**
 *
 * @author tambeotb4
 */
public class ServerSocketHandle extends Thread{
    private ServerSocket serverSoc;
    private String name;
    private int port;
    private BufferedReader in;
    private PrintWriter out;
    private Socket soc;
    public ServerSocketHandle(String name,int port) throws IOException{
        this.name = name;
        this.port=port;
        serverSoc = new ServerSocket(port);
        System.out.println("3");
    }
    @Override
    public void run(){
        try {
            soc = serverSoc.accept();
            out = new PrintWriter(soc.getOutputStream(), true);
            in = new BufferedReader(new InputStreamReader(soc.getInputStream()));
            ServerGui gui = new ServerGui(name, out, in);
            gui.setVisible(true);
            ServerInputStreamHandle sish = new ServerInputStreamHandle(in, out, gui);
            sish.start();
        } catch (IOException ex) {
            Logger.getLogger(ServerSocketHandle.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
